package com.itheima.service.impl;

import com.itheima.entity.ActRuDeadletterJob;
import com.itheima.dao.ActRuDeadletterJobDao;
import com.itheima.service.ActRuDeadletterJobService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (ActRuDeadletterJob)表服务实现类
 *
 * @author makejava
 * @since 2022-01-16 15:48:50
 */
@Service("actRuDeadletterJobService")
public class ActRuDeadletterJobServiceImpl implements ActRuDeadletterJobService {
    @Resource
    private ActRuDeadletterJobDao actRuDeadletterJobDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id_ 主键
     * @return 实例对象
     */
    @Override
    public ActRuDeadletterJob queryById(String id_) {
        return this.actRuDeadletterJobDao.queryById(id_);
    }

    /**
     * 分页查询
     *
     * @param actRuDeadletterJob 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<ActRuDeadletterJob> queryByPage(ActRuDeadletterJob actRuDeadletterJob, PageRequest pageRequest) {
        long total = this.actRuDeadletterJobDao.count(actRuDeadletterJob);
        return new PageImpl<>(this.actRuDeadletterJobDao.queryAllByLimit(actRuDeadletterJob, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param actRuDeadletterJob 实例对象
     * @return 实例对象
     */
    @Override
    public ActRuDeadletterJob insert(ActRuDeadletterJob actRuDeadletterJob) {
        this.actRuDeadletterJobDao.insert(actRuDeadletterJob);
        return actRuDeadletterJob;
    }

    /**
     * 修改数据
     *
     * @param actRuDeadletterJob 实例对象
     * @return 实例对象
     */
    @Override
    public ActRuDeadletterJob update(ActRuDeadletterJob actRuDeadletterJob) {
        this.actRuDeadletterJobDao.update(actRuDeadletterJob);
        return this.queryById(actRuDeadletterJob.getId_());
    }

    /**
     * 通过主键删除数据
     *
     * @param id_ 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id_) {
        return this.actRuDeadletterJobDao.deleteById(id_) > 0;
    }
}
